package com.example.eddie.test.activity;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

import com.example.eddie.test.MyAdapter.FragAdapter;
import com.example.eddie.test.R;
import com.example.eddie.test.Util.BottomNavigationViewEx;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity{

    private ViewPager ViewPager;
    private BottomNavigationViewEx bottomNavigationBar;
    private List<Fragment> list = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        initView();
    }

    private void initView() {
        ViewPager = (android.support.v4.view.ViewPager) findViewById(R.id.view_pager);
        list.add(new FirFragment());
        list.add(new SecFragment());
        list.add(new ThrFragment());
        list.add(new FouFragment());

        FragAdapter fragAdapter = new FragAdapter(getSupportFragmentManager(), list);
        ViewPager.setAdapter(fragAdapter);

        bottomNavigationBar = (BottomNavigationViewEx) findViewById(R.id.bottom_navigation_bar);
        bottomNavigationBar.enableAnimation(true);
        bottomNavigationBar.enableShiftingMode(false);
        bottomNavigationBar.enableItemShiftingMode(false);
        bottomNavigationBar.enableShiftingMode(false);
        bottomNavigationBar.setupWithViewPager(ViewPager);
    }

}
